#include <iostream>
#include <fstream>
#include <string>
#include "solve.h"
#include "bigint.h"
#include "bigintptr.h"
using namespace std;
int main()
{
	ifstream input("input.txt");
	ofstream output("output.txt");
	BigInt num1;
	BigInt num2;
	BigInt ans;
	int n=0;
 	string act;
	input >> n;
	for(int i=0; i < n; ++i)
	{
		input >> num1 >> act >> num2;
		//cout << "Bu\n";
		if(Solve(num1, num2, act, ans))	
		{
			output << ans << endl;
		}
		else
		{
			output << "Error" << endl;
		}
	}
	return 0;
}
